package Aug7;

import java.util.*;

class Employee implements Comparable<Employee>
	{
	private int id;
	private String name;
	
	Employee()
		{
		Scanner in = new Scanner(System.in);
		System.out.print("Enter the ID: ");
		this.id = in.nextInt();
		System.out.print("Enter the Name: ");
		this.name = in.next();
		}
	
	int getId()
		{
		return this.id;
		}
	
	String getName()
		{
		return this.name;
		}
	
	public String toString()
		{
		return this.name;
		}
	
	public int compareTo(Employee e)	
		{
		return name.compareTo(e.getName());
		}	
	}

public class ComparableDemo
	{
	public static void main(String[] args) 
		{	
		Employee emp[] = new Employee[3];
		for(int i=0;i<emp.length;i++)
			emp[i] = new Employee();
		System.out.println("If the members being compared have equal value, the compaerTo() returns" + emp[2].compareTo(emp[2]));
		System.out.println("If the members being compared have equal value, the compaerTo() returns" + emp[2].compareTo(emp[1]));
		System.out.println("If the members being compared have equal value, the compaerTo() returns" + emp[2].compareTo(emp[0]));
		/*
		ArrayList<Employee> eList = new ArrayList<Employee>();
		eList.add(new Employee());
		eList.add(new Employee());
		eList.add(new Employee());
		System.out.println("Unsorted List : " + eList);
		Collections.sort(eList);
		System.out.println("Sorted List : " + eList);
		*/
		
		}

	}	
